﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace CCD
{
    public partial class ChoiceModelDialog : Form
    {
        public ChoiceModelDialog()
        {
            InitializeComponent();
            GetModelInfo();
        }

        private void GetModelInfo()
        {
            DirectoryInfo di = new DirectoryInfo(Paths.ModelPath);
            try
            {
                // Determine whether the directory exists.
                if (di.Exists)
                {
                    DirectoryInfo[] DirList = di.GetDirectories();

                    comboBox1.BeginUpdate();
                    for (int i = 0; i < DirList.Length; i++)
                    {
                        comboBox1.Items.Add(DirList[i].Name);
                    }
                    comboBox1.EndUpdate();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("The model directory loading process failed: {0}", e.ToString());
            }
            finally { }

            di = null;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedItem != null)
            {
                string SelecetedModel = comboBox1.SelectedItem.ToString();
                MainUI father = (MainUI)this.Owner;
                this.Close();
                father.GotoProcessUI(SelecetedModel);
            }
            else
                MessageBox.Show("Please choose a model!");
        }


    }
}
